package com.jimmyhsu.ecnudaowei.Utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.jimmyhsu.ecnudaowei.login.LoginActivity;

/**
 * Created by jimmyhsu on 2017/3/1.
 */

public class PreferenceUtils {
    public static void addToPreference(String name, Context context, String key, String value) {
        SharedPreferences sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString(key, value);
        editor.commit();
    }

    public static void addToPreference(String name, Context context, String key, boolean value) {
        SharedPreferences sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }

    public static SharedPreferences getPreference(Context context, String name) {
        return context.getSharedPreferences(name, Context.MODE_PRIVATE);
    }
}
